Skip to content

Added unit-test codecov upload#1092

Open
AdamSaleh wants to merge 2 commits into
redhat-developer:masterfrom
AdamSaleh:codecov_upload
Open

Added unit-test codecov upload#1092
AdamSaleh wants to merge 2 commits into
redhat-developer:masterfrom
AdamSaleh:codecov_upload

Conversation

@AdamSaleh
Copy link
Copy Markdown
Member

What type of PR is this?
/kind enhancement

What does this PR do / why we need it:
We should be tracking our code coverage, this should enable it in such away that it won't cause test to fail if upload fails.

@openshift-ci openshift-ci Bot added the kind/enhancement New feature or request label Feb 27, 2026
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Feb 27, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign varshab1210 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@AdamSaleh AdamSaleh force-pushed the codecov_upload branch 3 times, most recently from 781e926 to 54f6b6b Compare February 27, 2026 11:56
fi
curl -Os https://cli.codecov.io/latest/linux/codecov
chmod +x codecov
CODECOV_TOKEN="$(cat "${CODECOV_TOKEN_FILE}")" ./codecov upload-process --file cover.out
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also specify the flag "unit-tests" so we can distinguish between test types in a future once we start uploading e2e test coverage too?

e.g.

./codecov upload-process \
  --token "${CODECOV_TOKEN}" \
  --flag unit-tests \
  --file coverage.out

see the jira ticket for more details

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, fair point. Will add.

Comment thread scripts/openshiftci-presubmit-unittests.sh Outdated
@AdamSaleh AdamSaleh force-pushed the codecov_upload branch 4 times, most recently from 685a077 to 7345417 Compare February 27, 2026 14:51
Signed-off-by: Adam Saleh <adam@asaleh.net>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 4d47df1f-3bfa-42cb-80e1-7ee1367fbf63

📥 Commits

Reviewing files that changed from the base of the PR and between 3f9c477 and 7724d35.

📒 Files selected for processing (1)
  • scripts/openshiftci-presubmit-unittests.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/openshiftci-presubmit-unittests.sh

📝 Walkthrough

Summary by CodeRabbit

  • Chores
    • CI now attempts to upload unit-test coverage reports when credentials are present; uploads are verified and any failures are logged but do not fail the build.

Walkthrough

Adds a guarded Codecov upload step to the OpenShift CI presubmit unit test script: downloads a pinned Codecov CLI, verifies its SHA256, and uploads cover.out using a mounted token if present; upload failures are logged but do not fail the job.

Changes

Codecov integration in unit test CI

Layer / File(s) Summary
Codecov CLI download and upload
scripts/openshiftci-presubmit-unittests.sh
After unit tests complete, script conditionally downloads Codecov CLI and uploads coverage using a mounted token file at /var/run/codecov-token/CODECOV_TOKEN, verifying the binary SHA256 and ensuring upload errors do not fail the CI job.
sequenceDiagram
  participant presubmit_script as presubmit_script
  participant codecov_cli as codecov_v11_2_8
  participant codecov_service as Codecov
  presubmit_script->>codecov_cli: curl download binary
  presubmit_script->>codecov_cli: verify SHA256 checksum
  presubmit_script->>codecov_cli: ./codecov upload-process cover.out --flag unit-tests
  codecov_cli->>codecov_service: upload coverage using token
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding Codecov upload functionality to unit tests. It is specific and directly related to the primary modification in the changeset.
Description check ✅ Passed The description is directly related to the changeset, explaining the purpose (tracking code coverage) and the implementation approach (non-blocking upload). It provides meaningful context about the PR's intent.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/openshiftci-presubmit-unittests.sh`:
- Around line 39-41: Replace the unpinned fetch of the Codecov CLI (the curl of
https://cli.codecov.io/latest/linux/codecov and subsequent chmod +x and
execution via CODECOV_TOKEN="$(cat "${CODECOV_TOKEN_FILE}")" ./codecov
upload-process) with a pinned-version workflow: define a CODECOV_CLI_VERSION,
download the matching release binary URL (not "latest") and its published
checksum/signature, verify the downloaded binary against the checksum or
signature before marking executable, and fail the job if verification fails;
keep the same upload invocation (./codecov upload-process --flag unit-tests
--file cover.out) after verification. Ensure the script exits non-zero on
checksum/signature mismatch so the untrusted binary is never executed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 7f9af1b9-747c-450d-967a-db51fa652e80

📥 Commits

Reviewing files that changed from the base of the PR and between aacca24 and 66f634e.

📒 Files selected for processing (1)
  • scripts/openshiftci-presubmit-unittests.sh

Comment thread scripts/openshiftci-presubmit-unittests.sh Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
scripts/openshiftci-presubmit-unittests.sh (1)

33-44: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Prevent executing Codecov CLI when its SHA256 checksum verification fails

set +e inside the subshell means a non-zero sha256sum --check --status won’t stop the script, so chmod +x codecov and ./codecov upload-process ... can still run. Gate installation/execution on successful checksum verification.

Suggested fix
 (
   set +e
   CODECOV_TOKEN_FILE="/var/run/codecov-token/CODECOV_TOKEN"
@@
   CODECOV_VERSION="v11.2.8"
   CODECOV_SHA="8930c4bb30254a42f3d8c340706b1be340885e20c0df5160a24efa2e030e662b"
   curl -OSs --fail-with-body "https://cli.codecov.io/${CODECOV_VERSION}/linux/codecov"
-  echo "${CODECOV_SHA}  codecov" | sha256sum --check --status
+  if ! echo "${CODECOV_SHA}  codecov" | sha256sum --check --status; then
+    echo "Codecov CLI checksum verification failed; skipping upload"
+    exit 1
+  fi
   chmod +x codecov
   CODECOV_TOKEN="$(cat "${CODECOV_TOKEN_FILE}")" ./codecov upload-process --flag unit-tests --file cover.out
 ) || echo "Coverage upload to codecov.io failed, continuing"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/openshiftci-presubmit-unittests.sh` around lines 33 - 44, The script
currently ignores a failed SHA256 check because set +e allows execution to
continue; change the flow so that the sha256 verification (using CODECOV_SHA and
the sha256sum --check --status invocation) must succeed before making the
downloaded file executable and running CODECOV (chmod +x codecov and
CODECOV_TOKEN=... ./codecov upload-process). Implement a conditional or explicit
exit on failure around the sha256sum check (e.g., run the check and if it fails
exit non-zero) so that chmod +x codecov and the CODECOV_TOKEN export and
./codecov upload-process are only executed when the checksum passes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@scripts/openshiftci-presubmit-unittests.sh`:
- Around line 33-44: The script currently ignores a failed SHA256 check because
set +e allows execution to continue; change the flow so that the sha256
verification (using CODECOV_SHA and the sha256sum --check --status invocation)
must succeed before making the downloaded file executable and running CODECOV
(chmod +x codecov and CODECOV_TOKEN=... ./codecov upload-process). Implement a
conditional or explicit exit on failure around the sha256sum check (e.g., run
the check and if it fails exit non-zero) so that chmod +x codecov and the
CODECOV_TOKEN export and ./codecov upload-process are only executed when the
checksum passes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: c7538288-9a6e-4e98-b819-de4c5cd02ccc

📥 Commits

Reviewing files that changed from the base of the PR and between 66f634e and 3f9c477.

📒 Files selected for processing (1)
  • scripts/openshiftci-presubmit-unittests.sh

Pin the codecov CLI download to a specific version (v11.2.8) and
verify the SHA256 checksum before executing, addressing the
supply-chain risk of fetching an unpinned "latest" binary.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Adam Saleh <adam@asaleh.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants